package edu.ccut.saturn.studio.component.editor;

import org.eclipse.ui.PartInitException;
import org.eclipse.wst.sse.ui.StructuredTextEditor;
import org.w3c.dom.Document;


import edu.ccut.saturn.studio.component.model.ComponentModel;
import edu.ccut.saturn.studio.component.page.ComponentPage;
import edu.ccut.saturn.studio.core.util.eclipse.SaturnXMLFormEditor;

public class ComponentFileEditor extends SaturnXMLFormEditor {
	
	public static final String SATURN_COMPONENT_FILE_EDITOR = ComponentFileEditor.class
			.getName();

	private ComponentModel componentModel;
	private ComponentPage page;

	public ComponentModel getComponentModel() {
		return componentModel;
	}

	protected void addFormPages() throws PartInitException {
		page = new ComponentPage(this);
		
		addPage(0, page);
		setPageText(0, "View"); //$NON-NLS-1$
	}

	@Override
	protected void initModel() {
		StructuredTextEditor sourcePage = super.getTextEditor();
		componentModel = new ComponentModel((Document) sourcePage
				.getAdapter(Document.class));
	}
}
